package com.css.fxfzypg.modules.rating.library.dao;

import com.css.fxfzypg.modules.rating.library.model.entity.KpExamIndex3PeekData;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Repository;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 系统评分，第26条，平台数据更新指标所选择的数据分类关系表
 */
@Slf4j
@Repository
public class KpExamIndex3PeekDataDao {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private NamedParameterJdbcTemplate namedParameterJdbcTemplate;

    public void insert(KpExamIndex3PeekData peekData) {
        String sql = "INSERT INTO kp_exam_index3_peek_data(id, kesdi3_id, data_type_code, create_time, create_user) values(:id, :kesdi3Id, :dataTypeCode, :createTime, :createUser)";
        namedParameterJdbcTemplate.update(sql, new BeanPropertySqlParameterSource(peekData));
    }

    public List<KpExamIndex3PeekData> selectByKesdi3id(String kesdi3Id) {
        String sql = String.format("select * from kp_exam_index3_peek_data where kesdi3_id = '%s'", kesdi3Id);
        return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(KpExamIndex3PeekData.class));
    }

    public void deleteByKesdi3Id(String index3Id) {
        String sql = String.format("delete from kp_exam_index3_peek_data where kesdi3_id = '%s'", index3Id);
        jdbcTemplate.update(sql);
    }
}